<?php
# +--------------------------------------------------------
# |Description: 阳光公采接口：公共逻辑处理类
# +--------------------------------------------------------
# |Company: 北京申合信科技发展有限公司
# +--------------------------------------------------------
# |WebSite: www.shenhexin.com
# +--------------------------------------------------------
# |Author: Akon<18363851918@163.com>
# +--------------------------------------------------------
# |Date: 2017年6月23日
# +--------------------------------------------------------

namespace Api\Event;

class CommonEvent{
    /**
     * 校验access_token
     * @param $access_token access_token
     */
    function checkAccessToken($access_token){
        $this->errorMsg($access_token,'error token!');        //校验access_token是否传递
        $user_info = M('User','','DB_CONFIG1')->where(array('access_token'=>$access_token))->find();
        $expire    = $user_info['create_time'] + 43200;
        $this->errorMsg($user_info,'error token!');          //校验access_token是否正确
        if($expire < time()){                                //校验access_token是否过期
            $info = array(
                'success' => 'false',
                'desc'    => 'token_expired'
            );
            $this->ajaxReturn($info);
        }
    }

    /**
     * 校验参数是否合法
     * @param $param  传递过来的参数
     */
    function errorMsg($param,$msg){
        if(!$param) {
            $res = array(
                'success' => 'false',
                'desc' => $msg
            );
            $this->ajaxReturn($res);
        }
    }
}